package com.example.dubbo.provider;


import com.example.dubbo.api.ReturnObjService;
import com.example.dubbo.dto.Result;
import org.apache.dubbo.rpc.RpcContext;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class ReturnByteServiceImpl implements ReturnObjService {

    @Override
    public Result<byte[]> sendMessage(String name) {
        System.out.println("return " + name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
        byte[] encode = Base64.getEncoder().encode(name.getBytes(StandardCharsets.UTF_8));
        return Result.success(encode);
    }
}
